<?php
/**
 * This file is part of PHPlaza (xhttp://code.google.com/p/phplaza)
 * This file is licensed under the GNU Lesser General Public License
 *      http://www.gnu.org/licenses/lgpl.html
 *
 * No warranty is given, express or implied. Use at your own risk.
 */
 
namespace core::services::stateservice;

use core::collections as col;

class SessionStateService implements core::services::IStateService
{
	const PAGE = 'page';
	const STATE = 'state';
	
	private $session;
	
	public function __construct()
	{
		session_start();
		
		$this->session = new col::SessionData();
	}
	
	public function previousPageExists()
	{
		return isset($this->session[self::PAGE]);
	}
	
	public function getPreviousPage() 
	{
		return $this->session[self::PAGE];
	}
	
	public function setCurrentPage(core::Page $page)
	{
		$this->session[self::PAGE] = $page->getId();
	}
	
	public function getPageState()
	{
		return $this->session[self::STATE];
	}
	
	
	public function setPageState(core::components::State $state)
	{
		$this->session[self::STATE] = $state;
	}
}